package week_02;

public class MaxDepth_104 {
    public int maxDepth(TreeNode root) {
        return clac(root).maxDepth;
    }


    public Info clac(TreeNode node) {
        // 空终止
        if (node == null) return new Info();
        // 需要收集：最大值深度
        // 收集左树信息
        Info left = clac(node.left);
        //收集右树信息
        Info right = clac(node.right);
        // 处理当前节点的信息
        int max = Math.max(left.maxDepth, right.maxDepth) + 1;
        // 返回结果
        Info info = new Info();
        info.maxDepth = max;
        return info;
    }

    public class Info {
        private int maxDepth;

        public Info() {
            this.maxDepth = 0;
        }
    }
}
